package work5;

/**
 * @TODO
 * @Author xu
 * 2025/2/26
 */
public class Work4 {
    public static void main(String[] args) {
        String fileName = "picture.jpeg";
        String format = getImageFormat(fileName);
        System.out.println("图片格式: " + format);
    }

    public static String getImageFormat(String fileName) {
        int dotIndex = fileName.lastIndexOf('.');
        if (dotIndex != -1 && dotIndex < fileName.length() - 1) {
            return fileName.substring(dotIndex + 1);
        }
        return "未知格式";
    }

}
